<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Photo extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $this->load->model('User_model');
        $this->load->model('Usernum_model');
    }
	

	public function index($albumid)
	{

		$this->load->model('Album_model');
		$o = $this->Album_model->get_info_by_id($albumid);
		if($o)
		{
			$userid = $o['userid'];

			//浏览
			$sysVisittype = _get_config('visittype');
			$this->load->service('user_service');
			$this->user_service->visit($userid, $this->loginID, $sysVisittype['home']);
			//-浏览

			$oUser = $this->user_service->get_user_homeinfo($userid, $this->loginID);
			
			$insid = $oUser['insid'];
			if(!empty($insid)) {
				$ins_user = $this->User_model->get_info_by_id($insid);
			}

			$arrWhere = array('albumid'=>$albumid,'status'=>1);
			$this->load->model('Photo_model');
			$list = $this->Photo_model->get_list($arrWhere,'id,img,title');

			//用户类型、分类
			$userRole = '';
			if ($oUser['usertype'] == 1)
			{
				$userRole = $oUser['role']?$oUser['role']:'模特';
			}
			elseif ($oUser['usertype'] == 2)
			{
				$oSysType = _get_config('type');
				$oSysType = $oSysType[2];
				$oSysStr = '';
				foreach ($oSysType as $key => $v)
				{
					if(strpos(','.$oUser['type'].',',','.$key.',')>-1)
					{
						if ($oSysStr)
						{
							$oSysStr .= ','.$v;
						}
						else
						{
							$oSysStr = $v;
						}
					}
				}
				$userRole = $oSysStr?$oSysStr:'机构';
			}
			elseif ($oUser['usertype'] == 3)
			{
				$userRole = '公司';
			}
			elseif ($oUser['usertype'] == 4)
			{
				$userRole = $oUser['role']?$oUser['role']:'摄影师';
			}
			elseif ($oUser['usertype'] == 5)
			{
				$userRole = $oUser['role']?$oUser['role']:'化妆师';
			}
			elseif ($oUser['usertype'] == 6)
			{
				if ($oUser['role'])
				{
					$userRole = $oUser['role'];
				}
				else
				{
					if ($oUser['type'])
					{
						$oSysType = _get_config('type');
						$oSysType = $oSysType[6];
						$userRole = $oSysType[$oUser['type']];
					}
					else
					{
						$userRole = '艺人';
					}
				}
			}
			
			$result = array(
				'oUser' => $oUser,
				'list' => $list,
				'userRole' => $userRole
				);
			if (isset($ins_user))
			{
				$result['ins_user'] = $ins_user;
			}

			$this->load->view('i/photo',$result);

		}
		
	}

}